package com.jx.driving.response;

import com.jx.driving.message.TimeTerminalRequestMessage;
import com.jx.driving.protocol.terminal.annotation.TerminalAnnotation;

/**
 * 服务端通用应答消息
 * 
 * @author wuxiaozeng
 *
 */
@TerminalAnnotation
public class Terminal0x8001Response extends AbstractResponse {
	public Terminal0x8001Response(Integer sequence, Integer id, ResponseResultStatus result) {
		super();
		this.sequence = sequence;
		this.id = id;
		this.result = (short) result.ordinal();
	}

	public Terminal0x8001Response() {
		super();
	}

	/**
	 * 根据request构造服务器通用应答
	 */
	public static Terminal0x8001Response buildFromTimeTerminalRequest(TimeTerminalRequestMessage request,
			ResponseResultStatus result) {
		return new Terminal0x8001Response(request.getSeq(), request.getMsgId(), result);
	}

	public static Terminal0x8001Response buildFromTimeTerminalRequest(TimeTerminalRequestMessage request, int msgId,
			ResponseResultStatus result) {
		return new Terminal0x8001Response(request.getSeq(), msgId, result);
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Terminal0x8001Response [sequence=").append(sequence).append(", id=").append(id)
				.append(", result=").append(result).append("]");
		return builder.toString();
	}

}
